package cn.edu.zut.internship.web.controller.company;

import cn.edu.zut.internship.bean.sys.Result;
import cn.edu.zut.internship.bean.sys.SysUser;
import cn.edu.zut.internship.iservice.company.BindingSV;
import cn.edu.zut.internship.web.utils.UserInfoUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/binding")
public class BindingController {
    @Reference
    BindingSV bindingSV;

    /**
     * 列表查询所有学生的实训单位绑定情况
     * @param params
     * @return
     */
    @RequestMapping("/selectBinding")
    public Result selectBinding(@RequestBody Map params) {
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("userInfo",userInfo);
        result = bindingSV.selectBinding(params);
        return result;
    }
    /**
     * 导出学生实训单位信息
     * @param params
     * @return
     */
    @RequestMapping("/exportBinding")
    public Result exportBinding(@RequestBody Map params) {
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("userInfo",userInfo);
        result = bindingSV.exportBinding(params);
        return result;
    }

    /**
     * 获取学生实训历史
     * @param params
     * @return
     */
    @RequestMapping("/getCompanyHistory")
    public Result getCompanyHistory(@RequestBody Map params) {
        Result result = new Result();
        result = bindingSV.getCompanyHistory(params);
        return result;
    }
    /**
     * 解除实训单位绑定关系
     * @param
     * @return
     */
    @RequestMapping("/cancelCompany")
    public Result cancelCompany() {
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        String studentAccount = userInfo.getUserAccount();
        result = bindingSV.cancelCompany(studentAccount);
        return result;
    }

    /**
     *
     * @return
     */
    @RequestMapping("/getStudentCompany")
    public Result getStudentCompany(@RequestBody Map params) {
        Result result = new Result();
        result = bindingSV.getStudentCompany(params);
        return result;
    }

    /**
     * 教师审核通过学生的实训信息
     * @param params
     * @return
     */
    @RequestMapping("/passStudentCompany")
    public Result passStudentCompany(@RequestBody Map params) {
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("userInfo",userInfo);
        result = bindingSV.passStudentCompany(params);
        return result;
    }
    /**
     * 教师驳回学生的实训信息
     * @param params
     * @return
     */
    @RequestMapping("/rejectStudentCompany")
    public Result rejectStudentCompany(@RequestBody Map params) {
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("userInfo",userInfo);
        result = bindingSV.rejectStudentCompany(params);
        return result;
    }

    /**
     * 检验登录学生当前是否已提交实训信息
     * @return
     */
    @RequestMapping("/testBinding")
    public Result testBinding() {
        Result result = new Result();
        Map params = new HashMap();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        params.put("userInfo",userInfo);
        result = bindingSV.testBinding(params);
        return result;
    }
}
